package com.gitee.poi.plugin.core.handler;

import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.Sheet;

import java.lang.reflect.Field;

public class FontProcessor extends AbstractProcessor implements HandlerAnnotation {

    private Class supportAnnotation = com.gitee.poi.plugin.annotations.core.Font.class;

    public CellStyle process(Font font, CellStyle style, Sheet sheet, Field field) {
        com.gitee.poi.plugin.annotations.core.Font f = field.getAnnotation(com.gitee.poi.plugin.annotations.core.Font.class);
        font.setFontName(f.fontName());
        font.setBold(f.bold());
        font.setItalic(f.italic());
        font.setStrikeout(f.strikeout());
        font.setFontHeightInPoints(f.fontSize());
        font.setColor(f.color().getIndex());
        font.setUnderline(f.underline());
        style.setFont(font);
        return style;
    }

    public Class getSupportAnnotation() {
        return supportAnnotation;
    }
}
